from random import randrange

class CreateHero:
    hp = 0
    power = 0
    hero_name = "null"
    def fight(self,power):
        ans = self.hp - power
        if ans < 0:
            print(f"{self.hero_name} die",ans)
        else:
            pass
        return ans

#创建对象timo
timo = CreateHero()
timo.hp = randrange(1,1000,1)
timo.power =randrange(1,500,1)
timo.hero_name = "timo"
print(f"timo的hp{timo.hp}和power{timo.power}")

#创建对象Jinx
Jinx = CreateHero()
Jinx.hp = randrange(1,1000,1)
Jinx.power =randrange(1,500,1)
Jinx.hero_name = "Jinx"
print(f"Jinx的hp{Jinx.hp}和power{Jinx.power}")

timo_ans = timo.fight(Jinx.power)
jinx_ans = Jinx.fight(timo.power)
print(f"timo_ans差值:{timo_ans}")
print(f"jinx_ans差值:{jinx_ans}")

if timo_ans > jinx_ans:
    print(f"{timo.hero_name} win")
elif timo_ans < jinx_ans:
    print(f"{Jinx.hero_name} win")
elif timo_ans == jinx_ans:
    print("平手")
else:
    raise Exception("异常")
